home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / objectex / ex15.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  740 b   |  31 lines

  1. Program ex15;
  2.  
  3. { Program to demonstrate the TStream.Flush method }
  4.  
  5. Uses Objects;
  6.  
  7. Var L : String;
  8.     P : PString;
  9.     S : PBufStream; { Only one with Flush implemented. }
  10.     
  11. begin
  12.   L:='Some constant string';
  13.   { Buffer size of 100 }
  14.   S:=New(PBufStream,Init('test.dat',stcreate,100));
  15.   Writeln ('Writing "',L,'" to stream with handle ',S^.Handle);
  16.   S^.WriteStr(@L);
  17.   { At this moment, there is no data on disk yet. }
  18.   S^.Flush;
  19.   { Now there is. }
  20.   S^.WriteStr(@L);
  21.   { Close calls flush first }
  22.   S^.Close;
  23.   Writeln ('Closed stream. File handle is ',S^.Handle);
  24.   S^.Open (stOpenRead);
  25.   P:=S^.ReadStr;
  26.   L:=P^;
  27.   DisposeStr(P);
  28.   Writeln ('Read "',L,'" from stream with handle ',S^.Handle);
  29.   S^.Close;
  30.   Dispose (S,Done);
  31. end.